package bigPack.dao.impl;

import bigPack.dao.UserDao;
import bigPack.pojo.user;

public class UserDaoImpl extends BaseDao implements UserDao {


    @Override
    public user queryUserByUsername(String username) {
        String sql="select `id`,`username`,`password`,`email` from t_user where username=? ";
        return  queryForOne(user.class,sql,username);
    }


    @Override
    public user queryUserByUsernameAndPassword(String username,String password) {
        String sql="select `id`,`username`,`password`,`email` from t_user where username=? and password=?";
        return (user) queryForOne(user.class,sql,username,password);
    }

    @Override
    public int saveUser(user user) {
        String sql="insert into t_user(`username`,`password`,`email`)values(?,?,?);";
        return update(sql,user.getUsername(),user.getPassword(),user.getEmail());
    }
}
